<?php

namespace app\controllers;

use app\models\Users;
use \yii\web\Response;
use \Yii;

Yii::$app->response->format = Response::FORMAT_JSON;

class UsersController extends \yii\web\Controller
{

    public function actionIndex()
    {
        $user = new Users();
        $user->attributes = ['name' => "123", 'password' => '123345', 'mobile' => "1231443"];
        $result = $user->save();
        return ['result' => $result];
    }

    public function actionGetUser()
    {
        $user = Users::findOne(['id' => $_REQUEST['id']]);
        if ($user == null) {
            return (Object)array();
        }
        unset($user->password);
        return $user->attributes;
    }

}
